<!DOCTYPE html>
<html>
  <head>
    {include file="common/meta" /}
  </head>
  <body class="layui-anim layui-anim-up">
    <div class="x-body">
        <!-- 搜索 -->
      <div class="layui-row">
        <form method="get" class="layui-form layui-col-md12 x-so">
          <input class="layui-input" placeholder="开始日" name="start" id="start" value="" />

          <input class="layui-input" placeholder="截止日" name="end" id="end" value="" />

          <input type="text" name="keywords"  placeholder="请输入昵称或邮箱" autocomplete="off" value="" class="layui-input">
          
          <button class="layui-btn">
              <i class="layui-icon">&#xe615;</i>
          </button>
        </form>
        <xblock>
            <span class="x-right" style="line-height:40px;margin-top: -1em;">共有数据：{$count} 条</span>
        </xblock>
      </div>

      <!-- 分页列表 -->
      <table class="layui-table">
        <thead>
          <tr>
            <th>充值用户</th>
            <th>充值金额</th>
            <th>充值时间</th>
            <th>备注内容</th>
            <th>审核人</th>
            <th>审核状态</th>
            <th>充值审核</th></tr>
        </thead>
        <tbody>
            {foreach $paylist as $item}
            <tr>
                <td>{$item.users.nickname}</td>
                <td>{$item.point}</td>
                <td>{$item.createtime}</td>
                <td>{$item.content}</td>
                {if condition="$item.adminid"}
                    <td>{$item.admins.username}</td>
                {else /}
                    <td>等待管理员审核</td>
                {/if}
                <td>{$item.status_text}</td>
                
                <td class="td-manage">
                    {if condition="$item.status==0"}
                        <a class="layui-btn layui-btn-sm layui-btn-normal" onclick="pass(`{$item.id}`)" >
                            通过
                        </a>
                        <a class="layui-btn layui-btn-sm layui-btn-normal" onclick="onpass(`{$item.id}`)" style="background-color: red;" >
                            不通过
                        </a>
                    {elseif condition="$item.status==1"}
                        <a class="layui-btn layui-btn-sm layui-btn-normal" >
                            已通过
                        </a>
                    {elseif condition="$item.status==2"}
                        <a class="layui-btn layui-btn-sm layui-btn-normal" style="background-color: red;" >
                            不通过
                        </a>
                    {/if}
                </td>
            </tr>
            {/foreach}
        </tbody>
      </table>

      <!-- 分页 -->
      <div class="page">
        {$pagestr}
      </div>
    </div>
  </body>
</html>


<script>
    // 同意
    function pass(id){
        layer.confirm('确认要通过吗？',function(pay){        
            $.ajax({
                url:`{:url('admin/user.pay/pass')}`,
                type:'post',
                data:`ids=${id}`,
                dataType:'json',
                success:function(success){
                    layer.msg(success.msg,{icon:5,time:1000},function(){
                        location.reload()
                    })
                }
            })
        });
    }
    
    // 不同意
    function onpass(id){
        layer.confirm('确认不通过吗？',function(pay){
        
            $.ajax({
                url:`{:url('admin/user.pay/onpass')}`,
                type:'post',
                data:`ids=${id}`,
                dataType:'json',
                success:function(success){
                    layer.msg(success.msg,{icon:5,time:1000},function(){
                        location.reload()
                    })
                }
            })
        });
    }
    
</script>